// jingang-quan.c -大金刚拳
// Modified by Venus Oct.1997


let includes = ([
    "include/common.js",
]);
// //继承哪些JS 在所有代码之前要完成继承
// let inherits = ([
//     "inherit/data.js",
//     "inherit/skill.js",
// ]);


let actions = [
    {
        "action": "$N盘膝而坐，二手合十，一式「莲花座」，双拳蓄势而发，击向$n的$l",
        "force": 120,
        "dodge": 10,
        "damage": 30,
        "lvl": 0,
        "skill_name": "莲花座",
        "damage_type": "瘀伤"
    },
    {
        "action": "$N一式「烈火锥」，双掌轮流下击，拳势如焰，吡啪爆响",
        "force": 170,
        "dodge": 15,
        "damage": 45,
        "lvl": 40,
        "skill_name": "烈火锥",
        "damage_type": "瘀伤"
    },
    {
        "action": "$N腾空飞起，一式「八方雨」，双手双腿齐出，令$n无可躲藏",
        "force": 220,
        "dodge": 25,
        "damage": 60,
        "lvl": 70,
        "skill_name": "八方雨",
        "damage_type": "瘀伤"
    },
    {
        "action": "$N双掌虚含，掌缘下沉，一式「掌心雷」，缓缓向$n推出",
        "force": 270,
        "dodge": 25,
        "damage": 70,
        "lvl": 100,
        "skill_name": "掌心雷",
        "damage_type": "瘀伤"
    },
    {
        "action": "$N一臂前伸，一臂后指，一式「五指山」，攻向$n的身前身后",
        "force": 320,
        "dodge": 30,
        "damage": 80,
        "lvl": 120,
        "skill_name": "五指山",
        "damage_type": "瘀伤"
    },
    {
        "action": "$N一式「观音渡」，两手十指虚点$n的全身三十六道要穴",
        "force": 340,
        "dodge": 35,
        "damage": 85,
        "lvl": 140,
        "skill_name": "观音渡",
        "damage_type": "瘀伤"
    },
    {
        "action": "$N两目内视，双手内笼，一式「天龙唱」，四面八方响起震人心魄的龙吟",
        "force": 360,
        "dodge": 35,
        "damage": 90,
        "lvl": 160,
        "skill_name": "天龙唱",
        "damage_type": "瘀伤"
    },
    {
        "action": "$N似笑非笑，双拳无形无定，一式「如来笑」，骤然击向$n的前胸",
        "force": 395,
        "dodge": 40,
        "damage": 100,
        "lvl": 180,
        "skill_name": "如来笑",
        "damage_type": "瘀伤"
    }
];


function validEnable(usage) {
    return usage == "cuff" || usage == "parry";
}

function validLearn(ob) {

    if (ob.getTemp("weapon") || ob.getTemp("secondary_weapon")) {
        return notify_fail("练大金刚拳必须空手。\n");
    }

    if (ob.querySkill("force") < 30) {
        return notify_fail("你的内功火候不够，无法学大金刚拳。\n");
    }

    if ( ob.get("max_neili") < 100 )
        return notify_fail("你的内力太弱，无法练大金刚拳。\n");

    if (ob.querySkill("cuff", 1) < ob.querySkill("jingang-quan", 1)) {
        return notify_fail("你的基本拳法水平有限，无法领会更高深的大金刚拳。\n");
    }
    return 1;
}

function querySkillName(level) {
    for (let sk in actions) {
        if (actions[sk].lvl == level) {
            return actions[sk].skill_name;
        }
    }
}

function queryAction(ob, weapon) {
    //querySkill 是skill.js中的方法
    let level = ob.querySkill("jingang-quan", 1);
    let useSks = actions.filter( e =>{
        if(level>=e.lvl) return e;
    });
    //getRandomOneOfArr 是common.js中的方法
   return  getRandomOneOfArr(useSks);
}

function practiceSkill(ob) {

    if (ob.getTemp("weapon") || ob.getTemp("secondary_weapon")) {
        return notifyFail("你必须空手练习！\n");
    }

    if (ob.get("qi") < 70) {
        return notifyFail("你的体力太低了。\n");
    }

    if (ob.get("neili") < 70) {
        return notifyFail("你的内力不够练大金刚拳。\n");
    }


    ob.receiveDamage("qi", 59);
    ob.add("neili", -58);
    return 1;
}

function performActionFile(action) {
    return __DIR__ + "jingang-quan/" + action;
}
